package com.fingard.dsp.bank.directbank.czb03;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;
import com.fingard.FGBiz;
import com.fingard.constant.Format;
import com.fingard.db.JDBCHelper;
import com.fingard.dsp.bank.directbank.bankInterface.IElecBillQuery;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.*;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB001OperBillQryDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB006BillStateQryDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB008HistoricalBillQryDetail;
import com.fingard.text.StringHelper;
import com.fingard.util.DateHelper;
import com.google.gson.Gson;

import java.sql.Connection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description TODO
 * @Author xtt
 * @Date $ $
 **/
public class CZB03ElecBill extends CZB03Base implements IElecBillQuery {
    @Override
    public RetAtsB001OperBillQry D_OperBill_Query_Req(ReqB001OperBillQry query) throws Exception {
        RetAtsB001OperBillQry retAts = new RetAtsB001OperBillQry(query.reqHeader);
        retAts.respCode = "0";
        retAts.writeBefore();
        while (query.readRecord()) {
            try {
                if ("1".equals(query.detail.queryType)) {
                    //查询申请类的票据
                    switch (Integer.valueOf(query.detail.busiType)) {
                        case 1:
                     //       queryOperBillByApply(query,retAts,"PJ2005");
                            break;//出票
                        case 2:
                            queryOperBillByTpye(query,retAts,"PJ0002");
                            break;//承兑
                        case 3:
                            queryOperBillByTpye(query,retAts,"PJ0008");
                            break;//提示收票
                        case 4:
                            queryOperBillByTpye017(query,retAts,"PJ0017");
                            break;//背书转让
                        case 5:
                            queryOperBillByTpye023(query,retAts,"05");
                            break;//质押
                        case 6:
                            queryOperBillByTpye023(query,retAts,"06");
                            break;//质押解除
                        case 10:
                            queryOperBillByTpye006(query,retAts,"PJ2006");
                            break;//贴现
                        case 12:
                            queryOperBillByTpye008(query,retAts,"PJ2008");
                            break;//提示付款
                        case 13:
                            queryOperBillByTpyePJ5002(query,retAts,"PJ5002","1");
                            break;//追索
                        case 14:
                            queryOperBillByTpyePJ5002(query,retAts,"PJ5006","1");
                            break;//同意清偿
                        default:
                            throw new Exception("未知的申请操作类型");
                    }
                } else if ("2".equals(query.detail.queryType)) {
                    //查询签收类的票据
                    switch (Integer.valueOf(query.detail.busiType)) {
                        case 1:
                            //       queryBillByApply(query,retAts,"PJ2005");
                            break;//出票
                        case 2:
                            queryBillBy007(query,retAts,"PJ0004","2");
                            break;//承兑
                        case 3:
                            queryBillBy010(query,retAts,"PJ0010","2");
                            break;//提示收票
                        case 4:
                            queryBillByTpye2020(query,retAts,"E");
                            break;//背书
                        case 5:
                            queryBillBy028(query,retAts,"3");
                            break;//质押
                        case 6:
                            queryBillBy028(query,retAts,"4");
                            break;//质押解除
                        case 10:
                            queryBillBy012(query,retAts,"PJ2012");
                            break;//贴现
                        case 12:
                            queryBillBy018(query,retAts,"14");
                            break;//提示付款
                        case 13:
                     //       queryBillByTpye(query,retAts,"16");
                            break;//追索
                        case 14:
                     //       queryBillByTpye(query,retAts,"20");
                            break;//同意清偿
                        default:
                            throw new Exception("未知的申请操作类型");
                    }
                } else {
                    //查询可撤销的票据
                    switch (Integer.valueOf(query.detail.busiType)) {
                        case 1:
                            //       queryBillByApply(query,retAts,"PJ2005");
                            break;//出票
                        case 2:
                            queryBillBy005(query,retAts,"PJ0005");
                            break;//承兑
                        case 3:
                            queryBillBy005(query,retAts,"PJ0011");
                            break;//提示收票
                        case 4:
                     //       queryBillByTpye(query,retAts,"06");
                            break;//背书转让
                        case 5:
                            queryBillBy028(query,retAts,"08");
                            break;//质押
                        case 6:
                  //          queryBillByTpye(query,retAts,"09");
                            break;//质押解除
                        case 10:
                            queryBillBy012(query,retAts,"PJ2012");
                            break;//贴现
                        case 12:
                            queryBillBy015(query,retAts,"PJ2015");
                            break;//提示付款
                        case 13:
                            queryOperBillByTpyePJ5002(query,retAts,"PJ5002","2");
                            break;//追索
                        case 14:
                            queryOperBillByTpyePJ5002(query,retAts,"PJ5006","2");
                            break;//同意清偿
                        default:
                            throw new Exception("未知的申请操作类型");
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                retAts = new RetAtsB001OperBillQry(query.reqHeader);
                retAts.writeBefore();
                retAts.respCode = "-1";
                retAts.respInfo = ex.getMessage();
            }
        }
        retAts.writeAfter();
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 票据操作明细查询
     * @param query
     * @return
     * @throws Exception
     */
    @Override
    public RetAtsB002BillTransQry D_B002_BillTrans_Query(ReqB002BillTransQry query) throws Exception {
        RetAtsB002BillTransQry retAts = new RetAtsB002BillTransQry(query.reqHeader);
        retAts.writeStart();
        return null;
    }

    @Override
    public RetAtsB004BillFrontQry D_B004_BillFront_Query(ReqB004BillFrontQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB005BillBackQry D_B005_BillBack_Query(ReqB005BillBackQry query) throws Exception {
        return null;
    }

    /**
     * 票据交易状态查询
     */
    @Override
    public RetAtsB006BillStateQry D_B006_BillState_Qeury(ReqB006BillStateQry query) throws Exception {
        RetAtsB006BillStateQry retAts = new RetAtsB006BillStateQry(query.reqHeader);
        retAts.writeBeforeDetail();
        while (query.readRecord()) {
            try {
                if ("1".equals(query.detail.operType)) {
                    //查询申请类的票据
                    switch (Integer.valueOf(query.detail.busiType)) {
                        case 1:
                            queryBillByTpye006(query,retAts);
                            break;//出票
                        case 2:
                            queryBillByTpye(query,retAts,"01");
                            break;//承兑
                        case 3:
                            queryBillByTpye006(query,retAts);
                            break;//提示收票
                        case 4:
                            queryBillByTpye006(query,retAts);
                            break;//背书转让
                        case 5:
                            queryBillByTpye(query,retAts,"08");
                            break;//质押
                        case 6:
                            queryBillByTpye(query,retAts,"09");
                            break;//质押解除
                        case 10:
                            queryBillByTpye(query,retAts,"10");
                            break;//贴现
                        case 12:
                            queryBillByTpye(query,retAts,"12");
                            break;//提示付款
                        case 13:
                            queryBillByTpye(query,retAts,"16");
                            break;//追索
                        case 14:
                            queryBillByTpye(query,retAts,"18");
                            break;//同意清偿
                        default:
                            throw new Exception("未知的申请操作类型");
                    }
                } else if ("2".equals(query.detail.operType) || "3".equals(query.detail.operType)) {
                    //查询签收类的票据
                    switch (Integer.valueOf(query.detail.busiType)) {
                        case 1:
                            //       queryBillByApply(query,retAts,"PJ2005");
                            break;//出票
                        case 2:
                            queryBillByTpye(query,retAts,"01");
                            break;//承兑
                        case 3:
                            queryBillByTpye006(query,retAts);
                            break;//提示收票
                        case 4:
                            queryBillByTpye(query,retAts,"07");
                            break;//背书
                        case 5:
                            //        queryBillByTpye(query,retAts,"08");
                            break;//质押
                        case 6:
                            //         queryBillByTpye(query,retAts,"09");
                            break;//质押解除
                        case 10:
                            //       queryBillByTpye(query,retAts,"10");
                            break;//贴现
                        case 12:
                            queryBillByTpye(query,retAts,"14");
                            break;//提示付款
                        case 13:
                            //       queryBillByTpye(query,retAts,"16");
                            break;//追索
                        case 14:
                            queryBillByTpye(query,retAts,"20");
                            break;//同意清偿
                        default:
                            throw new Exception("未知的申请操作类型");
                    }
                } else if("4".equals(query.detail.operType)){
                    //查询可撤销的票据
                    switch (Integer.valueOf(query.detail.busiType)) {
                        case 1:
                            //       queryBillByApply(query,retAts,"PJ2005");
                            break;//出票
                        case 2:
                            //           queryBillByTpye(query,retAts,"01");
                            break;//承兑
                        case 3:
                            queryBillByTpye(query,retAts,"04");
                            break;//提示收票
                        case 4:
                            queryBillByTpye(query,retAts,"06");
                            break;//背书转让
                        case 5:
                            //        queryBillByTpye(query,retAts,"08");
                            break;//质押
                        case 6:
                            //          queryBillByTpye(query,retAts,"09");
                            break;//质押解除
                        case 10:
                            queryBillByTpye(query,retAts,"11");
                            break;//贴现
                        case 12:
                            queryBillByTpye(query,retAts,"13");
                            break;//提示付款
                        case 13:
                            queryBillByTpye(query,retAts,"17");
                            break;//追索
                        case 14:
                            queryBillByTpye(query,retAts,"19");
                            break;//同意清偿
                        default:
                            throw new Exception("未知的申请操作类型");
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                retAts = new RetAtsB006BillStateQry(query.reqHeader);
                retAts.writeRespCode("-1");
                retAts.writeRespInfo(ex.getMessage());
            }
        }
        retAts.writeEnd();
        return retAts;
    }

    @Override
    public RetAtsB007BillKzsrQry D_B007_BillKzsr_Query(ReqB007BillKzsrQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB008HistoricalBillQry D_B008_HistoricalBillQuery(ReqB008HistoricalBillQry query) throws Exception {
        RetAtsB008HistoricalBillQry retAts = new RetAtsB008HistoricalBillQry(query.reqHeader);
        retAts.respCode = "0";
        retAts.respInfo  = "";
        retAts.writeBefore();
        int pageNum = 1;
        int totalPage = 1;
        while (query.readRecord()) {
            for (int m = 1; m <= totalPage; m++) {
                HashMap<String, Object> body = new HashMap<String, Object>();
                HashMap<String, Object> json = new HashMap<String, Object>();
                Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
                prBill4YqtOutBean.put("billNo", query.detail.billNo);//票号
                prBill4YqtOutBean.put("custAccount", query.detail.actNum);//查询类型：1-多条；2-最新历史(单条)；
                prBill4YqtOutBean.put("queryType", "2");//1-多条；2-最新历史(单条)；

                Map<String, Object> page = new HashMap<String, Object>();
                page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
                page.put("currentPage", pageNum + "");
                prBill4YqtOutBean.put("page", page);

                JSONObject billReqInfoJson = new JSONObject(prBill4YqtOutBean);

                body.put("billReqInfo", billReqInfoJson.toJSONString());
                body.put("tradeCode", "PJ2021");//交易代码
                JSONObject bodyInfo = new JSONObject(body);
                CZB03Header czb01Header = new CZB03Header();
                czb01Header.transCode = "42";//API方式
                czb01Header.reqSeqNo = query.reqHeader.transSeqID;
                String reqStr = writeRequestJson(body, czb01Header);
                String[] retStrArr = sendToBank(reqStr);
                if (retStrArr[0].length() == 0) {
                    JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                    if (repInfo != null) {
                        String resultcode = repInfo.getString("resultcode");
                        String resultdesc = repInfo.getString("resultdesc");
                        if (resultcode != null && resultcode.equals("000000")) {
                            //获取body内容
                            String details = repInfo.getString("body");
                            Gson gson = new Gson();
                            JSONObject repBody = JSON.parseObject(details);
                            String errCode = repBody.getString("errCode");
                            String errMsg = repBody.getString("errMsg");
                            if (errCode != null && errCode.equals("000000")) {
                                HashMap<String, String> pageBody = new HashMap<String, String>();
                                JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                                //再进行一次转换
                                pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                                JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("billHistoryInfo4YqtOutBean"));

                                //分页参数
                                String totalRows = pageBody.get("totalPages");//总页数
                                totalPage = Integer.valueOf(totalRows);
                                String currentPage = pageBody.get("currentPage");//当前页条数
                                pageNum = Integer.valueOf(currentPage) + 1;

                                if (billRespInfoBodyArray != null) {
                                    for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                        RetAtsB008HistoricalBillQryDetail detail = new RetAtsB008HistoricalBillQryDetail();
                                        JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                        detail.billNo = query.detail.billNo;//票据号
                                        detail.billType = query.detail.billType;//票据类型
                                        detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//签收日期
                                        detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日
                                        detail.transFlag = billRespInfoBody.getString("forbidFlag").equals("1") ? "0" : "1";//不可转让标识
                                        detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                        detail.drawCode = "";//出票人组织代码
                                        detail.drawAct = billRespInfoBody.getString("remitter");
                                        ;//出票人账户
                                        detail.drawBnkName = billRespInfoBody.getString("remitter");//出票人开户行行名
                                        detail.payeeName = billRespInfoBody.getString("toName");//收款人名
                                        detail.payeeCode = billRespInfoBody.getString("toBankNo");
                                        detail.payeeAct = billRespInfoBody.getString("toAcctNo");//收款人账户
                                        detail.payeeBnkName = "";//收款人行名
                                        retAts.writeDetail(detail);
                                    }
                                } else {
                                    retAts.writeRespInfo("未查询到记录");
                                    retAts.writeRespCode("0");
                                }
                            } else {
                                retAts.respCode = "-1";
                                retAts.respInfo = errMsg;
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = resultdesc;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = "查询失败";
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }
        }
        retAts.writeEnd();
        return retAts;
    }

    @Override
    public RetAtsB009DrawBillQry D_B009_DrawBillQuery(ReqB009DrawBillQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB010ProtocolStateQry D_B010_ProtocolStateQuery(ReqB010ProtocolStateQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB011TransFlagQry D_B011_TransFlagQuery(ReqB011TransFlagQry query) throws Exception {
        return null;
    }

    public String pageParam(String pageSize,String pageNum){
        Map<String, Object> BillReqInfo = new HashMap<String, Object>();
        Map<String, Object> page = new HashMap<String, Object>();
        page.put("pageSize",pageSize);
        page.put("currentPage",pageNum);
        BillReqInfo.put("page", page);
        JSONObject pageJson = new JSONObject(BillReqInfo);
        return pageJson.toString();
    }

    /**
     *
     * @param query
     * @param retAts
     * @param transCode
     * @param way 1-已签收(我方发起，他方签收)；
     * 2-签收(他方发起，我方签收)；
     * 3-拒绝(我方发起，他方签收)；
     * 4-拒绝(他方发起，我方签收)；
     */
    public void queryBillBy007(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode,String way) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
        HashMap<String, Object> body = new HashMap<String, Object>();
        Map<String, Object> json = new HashMap<String, Object>();
        Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
        prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            if(StringHelper.isNullOrEmpty(query.detail.dueDateDown)){
                prBill4YqtOutBean.put("beginDueDt", getLastYearDate());//票面到期日
            }else {
                prBill4YqtOutBean.put("beginDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            }
            if(StringHelper.isNullOrEmpty(query.detail.dueDateUp)){
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }else {
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }
        prBill4YqtOutBean.put("operType", way);//操作类型


        Map<String, Object> page = new HashMap<String, Object>();
        page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
        page.put("currentPage", pageNum + "");
        json.put("page",page);

        json.put("promptAccept4YqtOutBean", prBill4YqtOutBean);
        JSONObject billReqInfoJson = new JSONObject(json);

        body.put("billReqInfo", billReqInfoJson.toJSONString());
        body.put("tradeCode", transCode);//交易代码
        JSONObject bodyInfo = new JSONObject(body);
        CZB03Header czb01Header = new CZB03Header();
        czb01Header.transCode = "42";//API方式
        czb01Header.reqSeqNo = query.reqHeader.transSeqID;
        String reqStr = writeRequestJson(body, czb01Header);
        String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("promptAcceptBill4YqtOutBeans"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                          //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillBy005(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            if(StringHelper.isNullOrEmpty(query.detail.dueDateDown)){
                prBill4YqtOutBean.put("beginDueDt", getLastYearDate());//票面到期日
            }else {
                prBill4YqtOutBean.put("beginDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            }
            if(StringHelper.isNullOrEmpty(query.detail.dueDateUp)){
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }else {
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);


            if(transCode.equals("PJ0005")) {
                json.put("promptAccept4YqtOutBean", prBill4YqtOutBean);
            }else{
                json.put("acptRC4YqtOutBean", prBill4YqtOutBean);

            }
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            JSONArray billRespInfoBodyArray = new JSONArray();
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            if(transCode.equals("PJ0005")) {
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("promptAcceptBill4YqtOutBeans"));
                            }else{
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("billContent4YqtOutBeans"));
                            }
                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate =DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillBy012(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("minBillAmount", query.detail.billAmtDown);//票面金额
            prBill4YqtOutBean.put("endDueDt", query.detail.billAmtUp);


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);

            json.put("discBillSearch4YqtOutBean", prBill4YqtOutBean);

            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("discBillBeanZs4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillBy028(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String way) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("operType", way);//操作类型


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);

            json.put("impawn4YqtOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ0028");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("rgctBillInfo4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillBy018(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String way) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);


            json.put("paySignSearch4YptOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ2018");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("paySignBill4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillBy010(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode,String way) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            if(StringHelper.isNullOrEmpty(query.detail.dueDateDown)){
                prBill4YqtOutBean.put("beginDueDt", getLastYearDate());//票面到期日
            }else {
                prBill4YqtOutBean.put("beginDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            }
            if(StringHelper.isNullOrEmpty(query.detail.dueDateUp)){
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }else {
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }
            prBill4YqtOutBean.put("operType", way);//操作类型


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);

            json.put("acptRC4YqtOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("billContent4YqtOutBeans"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = "030001";//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillBy015(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception{
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("billNo", query.detail.billNo);
            prBill4YqtOutBean.put("minDueDt", query.detail.dueDateUp.replace("-",""));//票面到期日开始
            prBill4YqtOutBean.put("maxDueDt", query.detail.billAmtDown.replace("-",""));//票面到期日结束，时间区间不超过三个月


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);

            json.put("promptPayment4YqtOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("promptPaymentBill4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            /*detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }*/
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    //          detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = errMsg;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resultdesc;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "查询失败";
                }
            }else {
                retAts.respCode = "-1";
                retAts.respInfo = "查询失败";
            }
        }
    }

    public void queryBillByApply(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode){
        Map<String, Object> body = new HashMap<String, Object>();
        Map<String, Object> BillReqInfo = new HashMap<String, Object>();//BillReqInfo请求业务数据体

        Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
        prBill4YqtOutBean.put("remitterCustAcct",query.detail.actNum);//客户账号
        prBill4YqtOutBean.put("isDeliver", getBankConfig().getValueAsString("isDeliver"));//是否自动提示收票：1-自动；0-人工提示收票
        prBill4YqtOutBean.put("warteeSign", "YQDJ");//电子签名，默认传YQDJ
        prBill4YqtOutBean.put("batchNo", query.reqHeader.reqSeqOrBatNo);//批次号(标记该批票据)，保证全局唯一
        prBill4YqtOutBean.put("billType", query.detail.billType);//票据类型

        prBill4YqtOutBean.put("dueDt",query.detail.dueDateDown);//票面到期日
        prBill4YqtOutBean.put("billMoney",query.detail.billAmtDown);//票面金额
        prBill4YqtOutBean.put("payee", "YQDJ");//票面收款人名称
        prBill4YqtOutBean.put("payeeAcct", query.reqHeader.reqSeqOrBatNo);//票面收款人账号
        prBill4YqtOutBean.put("payeeBank", query.detail.billType);//票面收款人开户行名称

        prBill4YqtOutBean.put("payeeBankNo",query.detail.actNum);//票面收款人开户行行号
        prBill4YqtOutBean.put("acceptor", getBankConfig().getValueAsString("isDeliver"));//承兑人名称
        prBill4YqtOutBean.put("acceptorAcct", "YQDJ");//承兑人账号
        prBill4YqtOutBean.put("acceptorBank", query.reqHeader.reqSeqOrBatNo);//承兑人开户行名称
        prBill4YqtOutBean.put("acceptorBankNo", query.detail.billType);//承兑人开户行行号


        prBill4YqtOutBean.put("protEndors", getBankConfig().getValueAsString("isDeliver"));//禁止背书标记：0-不禁止背书；1-禁止背书

        BillReqInfo.put("prBill4YqtOutBean", prBill4YqtOutBean);
        JSONObject billReqInfoJson = new JSONObject(BillReqInfo);

        body.put("remitRegister4YqtOutBean", billReqInfoJson.toString());
        body.put("tradeCode", "PJ2009");//交易代码
    }

    public void queryOperBillByTpye(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号getLastYearDate
            if(StringHelper.isNullOrEmpty(query.detail.dueDateDown)){
                prBill4YqtOutBean.put("beginDueDt", getLastYearDate());//票面到期日
            }else {
                prBill4YqtOutBean.put("beginDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            }
            if(StringHelper.isNullOrEmpty(query.detail.dueDateUp)){
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }else {
                prBill4YqtOutBean.put("endDueDt", getafterMouthDate());//到期日上限
            }
            if(transCode.equals("PJ0010")){
                prBill4YqtOutBean.put("operType", "2");//操作类型：1-待确认；2-待签收(他方发起，我方签收)；
            }

            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
          /* if(transCode.equals("PJ0010")){
                prBill4YqtOutBean.put("operType", "1");//操作类型：1-待确认；2-待签收(他方发起，我方签收)；
            }*/
            if("PJ0002".equals(transCode)){
                json.put("promptAccept4YqtOutBean", prBill4YqtOutBean);
            } else {
                json.put("acptRC4YqtOutBean", prBill4YqtOutBean);
            }
            json.put("page",page);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            JSONArray billRespInfoBodyArray = new JSONArray();
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            if(transCode.equals("PJ0008")){
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("billContent4YqtOutBeans"));
                            }else if(transCode.equals("PJ0002")){
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("promptAcceptBill4YqtOutBeans"));
                            }

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                           detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                     }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    if("PJ0008".equals(transCode)){
                                        detail.billStatus = "020006";
                                    } else {
                                        detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    }
                                    detail.billNo = billRespInfoBody.getString("billNo");
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryOperBillByTpye006(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("holdAcctNo", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("minDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            prBill4YqtOutBean.put("maxDueDt", query.detail.dueDateUp.replace("-",""));//到期日上限

            prBill4YqtOutBean.put("billNo", query.detail.billNo);//客户账号

            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);
            json.put("rcSearchBean4YqtOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("discBillBeanZs4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                        detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                    }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    detail.billNo = query.detail.billNo;
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryOperBillByTpye017(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("operType", "1");//查询类型：1-可背书转让查询；2-可背书撤回查询
            prBill4YqtOutBean.put("billNo", query.detail.billNo);//客户账号
            prBill4YqtOutBean.put("minDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            prBill4YqtOutBean.put("maxDueDt", query.detail.dueDateUp.replace("-",""));//到期日上限

            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("endorsement4YqtOutBean", prBill4YqtOutBean);
            json.put("page",page);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("endorsementResultOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                        detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                    }
                                    detail.drawName = billRespInfoBody.getString("outBillPerson");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注

                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryOperBillByTpyePJ5002(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode,String way) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("minDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            prBill4YqtOutBean.put("maxDueDt", query.detail.dueDateUp.replace("-",""));//到期日上限
            prBill4YqtOutBean.put("queryType",way);//1-查询可追索票据；2-查询可撤回追索票据

            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);
            json.put("recoursement4YqtOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            JSONArray billRespInfoBodyArray = new JSONArray();
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            if(transCode.equals("PJ5006")){
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("agreePaymentBillOutBean"));
                            }else {
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("recourseableBillInfoOutBean"));
                            }
                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                        detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                    }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    detail.billNo = query.detail.billNo;
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryOperBillByTpye008(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String transCode) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            prBill4YqtOutBean.put("billNo", query.detail.billNo);//客户账号
            prBill4YqtOutBean.put("minDueDt", query.detail.dueDateDown.replace("-",""));//票面到期日
            prBill4YqtOutBean.put("maxDueDt", query.detail.dueDateUp.replace("-",""));//到期日上限


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("page",page);
            json.put("promptPayment4YqtOutBean", prBill4YqtOutBean);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", transCode);//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("promptPaymentBill4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                        detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                    }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    detail.billNo = query.detail.billNo;
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryOperBillByTpye023(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String busType) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            Map<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//客户账号
            if(busType.equals("06")){
                prBill4YqtOutBean.put("operType", "2");//查询类型：1-可质押票据查询；2-可撤销质押票据查询；3-待解质押签收票据查询
            }else if(busType.equals("05")){
                prBill4YqtOutBean.put("operType", "1");//查询类型：1-可质押票据查询；2-可撤销质押票据查询；3-待解质押签收票据查询
            }

            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("rcBpImpawn4YqtOutBean", prBill4YqtOutBean);
            json.put("page",page);
            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ0023");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("rgctBillInfo4YqtOutBean"));

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                        detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                    }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    detail.billNo = query.detail.billNo;
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryBillByTpye006(ReqB006BillStateQry query,RetAtsB006BillStateQry retAts) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        String SerialNo = "";
        if("1".equals(query.detail.operType) && "1".equals(query.detail.busiType)){
            Connection conn = FGBiz.getLocalDbConn();
            Map<String, Object> selMap = JDBCHelper.execQuerySingle(conn, SELECTSEQ, new Object[]{query.detail.reqSeqID, query.reqHeader.bankCode});
            if (selMap!=null && selMap.size() > 0) {
                SerialNo = selMap.get("BANKREQSEQID").toString();
                WriteBankLogLn("映射核心流水号为：" + SerialNo);
            } else {
                retAts.writeRespInfo("查询失败:未找到映射的等级ID");
                retAts.writeRespCode("-1");
            }
        }
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            HashMap<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("billNo",query.detail.billNo);
            prBill4YqtOutBean.put("batNo", "");//批次号
            prBill4YqtOutBean.put("rgctId", SerialNo);//登记中心id
            prBill4YqtOutBean.put("billType", query.detail.billType);
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//票据类型operType
            prBill4YqtOutBean.put("operType", "3");//1-查询已出票票据信息；3-票据基本信息查询；

            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            json.put("billSearch4YqtOutBean", prBill4YqtOutBean);
            json.put("page",page);

            JSONObject billReqInfoJson = new JSONObject(json);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ2010");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
        //    String[] retStrArr = new String[]{"","{\"body\":{\"errMsg\":\"交易成功\",\"billRespInfo\":\"{\\\"billHistory4YqtOutBeans\\\":{[\\\"rgctId\\\":\\\"119147\\\",\\\"acceptorAcctNo\\\":\\\"0\\\",\\\"forbidFlag\\\":\\\"0\\\",\\\"remitterAcctNo\\\":\\\"3310010010120122848910\\\",\\\"curStatus\\\":\\\"B_08\\\",\\\"preStatus\\\":\\\"A_01\\\",\\\"fromAcctNo\\\":\\\"3310010010120122848910\\\",\\\"remitterBankNo\\\":\\\"316331000106\\\",\\\"isLock\\\":\\\"0\\\",\\\"payee\\\":\\\"银企直连成员单位测试一\\\",\\\"billMoney\\\":\\\"1.00\\\",\\\"dueDt\\\":\\\"20200614\\\",\\\"curEcdsStatus\\\":\\\"020001\\\",\\\"holdName\\\":\\\"银企直连主办单位测试一\\\",\\\"interest\\\":\\\"0.00\\\",\\\"payeeBankNo\\\":\\\"316331000106\\\",\\\"stepName\\\":\\\"提示承兑\\\",\\\"toName\\\":\\\"浙商银行股份有限公司杭州分行营业部\\\",\\\"endorseDt\\\":\\\"20200514\\\",\\\"fromName\\\":\\\"银企直连主办单位测试一\\\",\\\"signDt\\\":\\\"20200514\\\",\\\"billNo\\\":\\\"131633100010620200514000260797\\\",\\\"fromCustNo\\\":\\\"831594006\\\",\\\"interestRate\\\":\\\"0.000000\\\",\\\"acceptor\\\":\\\"浙商银行股份有限公司杭州分行营业部\\\",\\\"remitter\\\":\\\"银企直连主办单位测试一\\\",\\\"holdBankNo\\\":\\\"316331000106\\\",\\\"billType\\\":\\\"1\\\",\\\"toAcctNo\\\":\\\"0\\\",\\\"histId\\\":\\\"670589\\\",\\\"holdAcctNo\\\":\\\"3310010010120122848910\\\",\\\"payeeAcctNo\\\":\\\"3310010010120122858808\\\",\\\"acceptorBankNo\\\":\\\"316331000106\\\",\\\"payeeBankName\\\":\\\"浙商银行股份有限公司杭州分行营业部\\\",\\\"fromBankNo\\\":\\\"316331000106\\\",\\\"acptDt\\\":\\\"20200514\\\",\\\"draftInfo\\\":\\\"\\\",\\\"draftLock\\\":\\\"0\\\",\\\"toBankNo\\\":\\\"316331000106\\\",\\\"dealMoney\\\":\\\"0.00\\\"],[\\\"rgctId\\\":\\\"119147\\\",\\\"acceptorAcctNo\\\":\\\"0\\\",\\\"forbidFlag\\\":\\\"0\\\",\\\"remitterAcctNo\\\":\\\"3310010010120122848910\\\",\\\"curStatus\\\":\\\"B_08\\\",\\\"preStatus\\\":\\\"A_01\\\",\\\"fromAcctNo\\\":\\\"3310010010120122848910\\\",\\\"remitterBankNo\\\":\\\"316331000106\\\",\\\"isLock\\\":\\\"0\\\",\\\"payee\\\":\\\"银企直连成员单位测试一\\\",\\\"billMoney\\\":\\\"1.00\\\",\\\"dueDt\\\":\\\"20200614\\\",\\\"curEcdsStatus\\\":\\\"020001\\\",\\\"holdName\\\":\\\"银企直连主办单位测试一\\\",\\\"interest\\\":\\\"0.00\\\",\\\"payeeBankNo\\\":\\\"316331000106\\\",\\\"stepName\\\":\\\"提示承兑\\\",\\\"toName\\\":\\\"浙商银行股份有限公司杭州分行营业部\\\",\\\"endorseDt\\\":\\\"20200514\\\",\\\"fromName\\\":\\\"银企直连主办单位测试一\\\",\\\"signDt\\\":\\\"20200514\\\",\\\"billNo\\\":\\\"131633100010620200514000260797\\\",\\\"fromCustNo\\\":\\\"831594006\\\",\\\"interestRate\\\":\\\"0.000000\\\",\\\"acceptor\\\":\\\"浙商银行股份有限公司杭州分行营业部\\\",\\\"remitter\\\":\\\"银企直连主办单位测试一\\\",\\\"holdBankNo\\\":\\\"316331000106\\\",\\\"billType\\\":\\\"1\\\",\\\"toAcctNo\\\":\\\"0\\\",\\\"histId\\\":\\\"670589\\\",\\\"holdAcctNo\\\":\\\"3310010010120122848910\\\",\\\"payeeAcctNo\\\":\\\"3310010010120122858808\\\",\\\"acceptorBankNo\\\":\\\"316331000106\\\",\\\"payeeBankName\\\":\\\"浙商银行股份有限公司杭州分行营业部\\\",\\\"fromBankNo\\\":\\\"316331000106\\\",\\\"acptDt\\\":\\\"20200514\\\",\\\"draftInfo\\\":\\\"\\\",\\\"draftLock\\\":\\\"0\\\",\\\"toBankNo\\\":\\\"316331000106\\\",\\\"dealMoney\\\":\\\"0.00\\\"]},\\\"page\\\":{\\\"totalAmount\\\":\\\"0.0\\\",\\\"totalPages\\\":\\\"1\\\",\\\"pageSize\\\":\\\"10\\\",\\\"totalRows\\\":\\\"1\\\",\\\"currentPage\\\":\\\"1\\\",\\\"currentPageTotalRows\\\":\\\"1\\\"}}\",\"success\":true,\"errCode\":\"000000\"},\"orgmsgid\":\"1550144473\",\"orgmsgtype\":\"yqwfw_billYqzlService\",\"resultcode\":\"000000\",\"resultdesc\":\"交易成功\",\"senttime\":\"2020-05-14 15:51:23.440\",\"version\":\"1.0.0\"}"};
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {
                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //分页参数
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            String totalNums = pageBody.get("totalRows");//总页数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;
                            String detailBody = "";
                            if("1".equals(totalNums)){
                                 detailBody = "[" + billRespInfo.getString("billHistory4YqtOutBeans") + "]";
                            } else {
                                 detailBody = billRespInfo.getString("billHistory4YqtOutBeans") ;
                            }
                            JSONArray billRespInfoBodyArray = JSONArray.parseArray(detailBody);
                            //数据报文

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB006BillStateQryDetail detail = new RetAtsB006BillStateQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    String billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    if(StringHelper.isNullOrEmpty(billNo)){
                                        detail.respInfo = "银行处理中";
                                        detail.respCode = "0";
                                        detail.reqSeqID = query.detail.reqSeqID;
                                        detail.transState = billRespInfoBody.getString("curStatus");//票据状态
                                        detail.payInfoCode = detail.transState;
                                    } else {
                                        detail.respInfo = "交易成功";
                                        detail.respCode = "0";
                                        detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    /*detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = Format.Date10Format.format(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = Format.Date10Format.format(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = billRespInfoBody.getString("status");//票据状态
                                    */
                                        detail.reqSeqID = query.detail.reqSeqID;
                                        detail.transState = errCode;//票据状态
                                        detail.payInfoCode = errCode;
                                        detail.billState = billRespInfoBody.getString("curEcdsStatus");//票据状态
                                    }
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("查询无记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryBillByTpye5001(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String busiType) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            HashMap<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("billNo", query.detail.billNo);//客户账号
            prBill4YqtOutBean.put("batNo", "");//批次号
            prBill4YqtOutBean.put("rgctId", "");//登记中心id
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//请求人账号
            prBill4YqtOutBean.put("busiType", busiType);//票据类型


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            prBill4YqtOutBean.put("page",page);

            JSONObject billReqInfoJson = new JSONObject(prBill4YqtOutBean);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ5001");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {

                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            String totalPages = pageBody.get("totalPages");//总条数
                            JSONArray billRespInfoBodyArray = null;
                            if(StringHelper.changeStrToNum(totalPages)==1) {
                                billRespInfoBodyArray = JSONArray.parseArray("["+billRespInfo.getString("processInfoRegResultOutBean")+"]");
                            } else {
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("processInfoRegResultOutBean"));
                            }

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;
                            //数据报文

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("status"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryBillByTpye2020(ReqB001OperBillQry query,RetAtsB001OperBillQry retAts,String busiType) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            HashMap<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("billType", "1");//票据类型：1-银票；2商票
            prBill4YqtOutBean.put("billNo", query.detail.billNo);//批次号
            prBill4YqtOutBean.put("rgctId", "");//登记中心id
            prBill4YqtOutBean.put("custAccount", query.detail.actNum);//请求人账号
            prBill4YqtOutBean.put("minBillAmount", query.detail.billAmtDown);//票面金额下线
            prBill4YqtOutBean.put("maxBillAmount", query.detail.dueDateUp);//票面金额上限
            prBill4YqtOutBean.put("minDueDt", query.detail.dueDateUp.replace("-",""));//票面到期日开始
            prBill4YqtOutBean.put("maxDueDt", query.detail.billAmtDown.replace("-",""));//票面到期日结束，时间区间不超过三个月
            prBill4YqtOutBean.put("businessType", busiType);//票据类型


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            prBill4YqtOutBean.put("page",page);

            JSONObject billReqInfoJson = new JSONObject(prBill4YqtOutBean);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ2020");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {

                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());

                            //分页参数
                            String totalNums = pageBody.get("totalRows");//总条数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;
                            //数据报文
                            JSONArray billRespInfoBodyArray = null;
                            if(StringHelper.changeStrToNum(totalNums)==1) {
                                billRespInfoBodyArray = JSONArray.parseArray("["+billRespInfo.getString("rgctBill4YqtOutBeans")+"]");
                            } else {
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("rgctBill4YqtOutBeans"));
                            }
                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = DateHelper.convertD8toD10(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = DateHelper.convertD8toD10(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                                    detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                                    if("2".equals(query.detail.busiType)){
                                        detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                                    }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = this.getBankConfig().getMapValueByKey("billStatusMapping",billRespInfoBody.getString("curStatus"));//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }

    public void queryBillByTpye(ReqB006BillStateQry query,RetAtsB006BillStateQry retAts,String busiType) throws Exception {
        int pageNum = 1;
        int totalPage = 1;
        for (int m = 1; m <= totalPage; m++) {
            HashMap<String, Object> body = new HashMap<String, Object>();
            HashMap<String, Object> json = new HashMap<String, Object>();
            Map<String, Object> prBill4YqtOutBean = new HashMap<String, Object>();
            prBill4YqtOutBean.put("billNo", query.detail.billNo);//客户账号
            prBill4YqtOutBean.put("batNo", "");//批次号
            prBill4YqtOutBean.put("rgctId", "");//登记中心id
            prBill4YqtOutBean.put("fromAcctNo", query.detail.actNum);//请求人账号
            prBill4YqtOutBean.put("busiType", busiType);//票据类型


            Map<String, Object> page = new HashMap<String, Object>();
            page.put("pageSize", this.getBankConfig().getValueAsString("pageSize"));
            page.put("currentPage", pageNum + "");
            prBill4YqtOutBean.put("page",page);

            JSONObject billReqInfoJson = new JSONObject(prBill4YqtOutBean);

            body.put("billReqInfo", billReqInfoJson.toJSONString());
            body.put("tradeCode", "PJ5001");//交易代码
            JSONObject bodyInfo = new JSONObject(body);
            CZB03Header czb01Header = new CZB03Header();
            czb01Header.transCode = "42";//API方式
            czb01Header.reqSeqNo = query.reqHeader.transSeqID;
            String reqStr = writeRequestJson(body, czb01Header);
            String[] retStrArr = sendToBank(reqStr);
            if (retStrArr[0].length() == 0) {
                JSONObject repInfo = JSONObject.parseObject(retStrArr[1]);
                if (repInfo != null) {
                    String resultcode = repInfo.getString("resultcode");
                    String resultdesc = repInfo.getString("resultdesc");
                    if (resultcode != null && resultcode.equals("000000")) {
                        //获取body内容
                        String details = repInfo.getString("body");
                        Gson gson = new Gson();
                        JSONObject repBody = JSON.parseObject(details);
                        String errCode = repBody.getString("errCode");
                        String errMsg = repBody.getString("errMsg");
                        if (errCode != null && errCode.equals("000000")) {

                            HashMap<String, String> pageBody = new HashMap<String, String>();
                            JSONObject billRespInfo = JSON.parseObject(repBody.getString("billRespInfo"));
                            //再进行一次转换
                            pageBody = gson.fromJson(billRespInfo.getString("page"), pageBody.getClass());
                            String totalPages = pageBody.get("totalPages");//总条数
                            JSONArray billRespInfoBodyArray = null;
                            if(StringHelper.changeStrToNum(totalPages)==1) {
                                 billRespInfoBodyArray = JSONArray.parseArray("["+billRespInfo.getString("processInfoRegResultOutBean")+"]");
                            } else {
                                billRespInfoBodyArray = JSONArray.parseArray(billRespInfo.getString("processInfoRegResultOutBean"));
                            }

                            //分页参数
                            String totalRows = pageBody.get("totalPages");//总页数
                            totalPage = Integer.valueOf(totalRows);
                            String currentPage = pageBody.get("currentPage");//当前页条数
                            pageNum = Integer.valueOf(currentPage) + 1;
                            //数据报文

                            if (billRespInfoBodyArray != null) {
                                for (int i = 0; i < billRespInfoBodyArray.size(); i++) {
                                    RetAtsB006BillStateQryDetail detail = new RetAtsB006BillStateQryDetail();
                                    JSONObject billRespInfoBody = billRespInfoBodyArray.getJSONObject(i);
                                    detail.billNo = billRespInfoBody.getString("billNo");//电子票据号码
                                    /*detail.billType = billRespInfoBody.getString("billType");//票据类型 1-银承 2-商承
                                    detail.issDate = Format.Date10Format.format(billRespInfoBody.getString("acptDt"));//出票日(yyyy-MM-dd)
                                    detail.dueDate = Format.Date10Format.format(billRespInfoBody.getString("dueDt"));//到期日(yyyy-MM-dd)
                                    detail.billAmt = billRespInfoBody.getString("billMoney");//电子票据金额
                            detail.transFlag=billRespInfoBody.getString("billType");//背书转让标识 1-可再转让 0-不得转让
                            if("2".equals(query.detail.busiType)){
                                detail.mustPay="1";//承兑无条件支付委托 1-无条件支付 0-非条件支付
                            }
                                    detail.drawName = billRespInfoBody.getString("remitter");//出票人
                                    detail.drawCode = "";//出票人组织代码
                                    detail.drawAct = billRespInfoBody.getString("remitterAcct");//出票人账号
                                    detail.drawBnkName = "";//出票人开户行行名
                                    detail.drawBnkCode = billRespInfoBody.getString("remitterBankNo");//出票人开户行行号
                                    detail.accpName = billRespInfoBody.getString("acceptor");//承兑人名称
                                    detail.accpCode = "";//承兑人组织代码
                                    detail.accpAct = billRespInfoBody.getString("acceptorAcct");//承兑人账号
                                    detail.accpBnkName = "";//承兑人开户行行名
                                    detail.accpBnkCode = billRespInfoBody.getString("acceptorBankNo");//承兑人开户行行号
                                    detail.payeeName = billRespInfoBody.getString("payee");//收款人
                                    detail.payeeCode = "";//
                                    detail.payeeAct = billRespInfoBody.getString("payeeAcctNo");//收款人账号
                                    detail.payeeBnkName = "";//收款人开户行行名
                                    detail.payeeBnkCode = billRespInfoBody.getString("payeeBankNo");//收款人开户行行号
                                    detail.applyDate = "";//申请日期
                                    detail.applyName = "";//申请人
                                    detail.applyCode = "";//申请人组织机构代码
                                    detail.applyAct = billRespInfoBody.getString("fromAcctNo");//申请人账号
                                    detail.applyBnkCode = "";//申请人开户行行号
                                    detail.busiNo = billRespInfoBody.getString("batNo");//交易明细流水
                                    detail.busiType = query.detail.busiType;//操作标志
                                    detail.queryType = query.detail.queryType;//查询类型
                                    detail.memo = "";//备注
                                    detail.billStatus = billRespInfoBody.getString("status");//票据状态
                                    */
                                    detail.billNo = query.detail.billNo;
                                    detail.reqSeqID = query.detail.reqSeqID;
                                    detail.transState = errCode;//票据状态
                                    detail.payInfoCode = errCode;
                                    detail.billState = billRespInfoBody.getString("status");//票据状态
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                retAts.writeRespInfo("未查询到记录");
                                retAts.writeRespCode("0");
                            }
                        } else {
                            retAts.writeRespInfo(errMsg);
                            retAts.writeRespCode("-1");
                        }
                    } else {
                        retAts.writeRespInfo(resultdesc);
                        retAts.writeRespCode("-1");
                    }
                } else {
                    retAts.writeRespInfo("查询失败");
                    retAts.writeRespCode("-1");
                }
            }
        }
    }
}
